﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.RestrictedUsage.CSharp.Semantics;
using Microsoft.RestrictedUsage.CSharp.Syntax;

namespace CSharpParser.CSharpModel
{

    public static class MoreCSharpLanguageModelExtensions
    {
        // Methods
        public static string GetFullNamespace(this CSharpNamespace ns)
        {
            string text = null;
            while (ns.ContainingNamespace != null)
            {
                if (text == null)
                {
                    text = ns.Name.Text;
                }
                else
                {
                    text = ns.Name.Text + "." + text;
                }
                ns = ns.ContainingNamespace;
            }
            if (text == null)
            {
                text = "<global>";
            }
            return text;
        }

        public static IEnumerable<ParseTreeNode> SelectFileCodeItems(this ParseTree parseTree)
        {
            if (parseTree == null)
            {
                return new ParseTreeNode[0];
            }
            return new FileCodeItemsCollector(parseTree.RootNode);
        }
    }



}
